#include "MailerThread.h"
#include "ResaHotelGUI.h"

MailerThread::MailerThread(ResaHotelGUI* _parent, Mail* _mail, MailBox* _mailBox) : QThread(_parent){
	parent = _parent;
	mail = _mail;
	mailBox = _mailBox;

	//if(mailBox->shouldUseDefaultMailClient()){
		state = LAUNCH_DEFAULT_CLIENT;
	//}
	//else{
	//	state = SEND_MAIL;
	//}

	connect(this, SIGNAL(finished()), parent, SLOT(mailerThreadFinished()));
}

void MailerThread::run(void){

	switch (state){
	//case SEND_MAIL :
	//	mailBox->sendMail(mail)?state=SEND_OK:state=SEND_ERROR;
	//	break;

	case LAUNCH_DEFAULT_CLIENT :
		mailBox->sendMailWithDefaultClient(mail)?state=LAUNCH_OK:state=LAUNCH_ERROR;
		break;
	}

	quit();
}